﻿@{
    ViewBag.Title = "PrivateStaticMember";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<h2>Private Static Member</h2>

<script type="text/javascript">
    // constructor
    var Gadget = (function () {
        // static variable/property
        var counter = 0,
        NewGadget;

        // this will become the
        // new constructor implementation
        NewGadget = function () {
            counter += 1;
        };

        // a privileged method
        NewGadget.prototype.getLastId = function () {
            return counter;
        };

        // overwrite the constructor
        return NewGadget;
    }()); // execute immediately

    window.onload = function () {
        var iphone = new Gadget();
        var iphoneId = iphone.getLastId(); // 1

        var ipod = new Gadget();
        var ipodId = ipod.getLastId(); // 2

        var ipad = new Gadget();
        var ipadId = ipad.getLastId(); // 3

        ZEUS.DEBUG.log("iphone Id: " + iphoneId);
        ZEUS.DEBUG.log("ipod Id: " + ipodId);
        ZEUS.DEBUG.log("ipad Id: " + ipadId);
    };
</script>
